package com.lh.utils;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.LinkedList;
import java.util.List;

public class AnswerPage <T>{

    private List<T> rows;
    private long total;

    public static <T> AnswerPage<T> empty(){
        return new AnswerPage<T>(new LinkedList<T>(), 0);
    }

    public static <T> AnswerPage<T> build(Page<T> pageInfo){
        return new AnswerPage<T>(pageInfo.getRecords(), pageInfo.getTotal());
    }

    public AnswerPage(){

    }

    public AnswerPage(List<T> rows, long total){
        this.setRows(rows);
        this.setTotal(total);
    }

    public List<T> getRows() {
        return rows;
    }
    public void setRows(List<T> rows) {
        this.rows = rows;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }
}
